package com.sgu6.sgu6_machine.util;

import java.util.Calendar;

public class TimeUtil {

    public static String getTime() {
        Calendar calendar = Calendar.getInstance();
        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        int minute = calendar.get(Calendar.MINUTE);
        int second = calendar.get(Calendar.SECOND);
        String time = calendar.get(Calendar.YEAR) + "/"
                + (calendar.get(Calendar.MONTH) + 1) + "/"//从0计算
                + calendar.get(Calendar.DAY_OF_MONTH) + " "
                + (hour < 10 ? ("0" + hour) : hour) + ":"
                + (minute < 10 ? ("0" + minute) : minute) + ":"
                + (second < 10 ? ("0" + second) : second) + " 星期" + (calendar.get(Calendar.DAY_OF_WEEK) - 1) + " ";

        return time;
    }

}
